package com.example.hissys.service;

import com.example.hissys.entity.DoctorSchedule;
import com.example.hissys.mapper.ScheduleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import java.util.List;

@Service
@Slf4j
public class ScheduleService {
    @Autowired
    private ScheduleMapper scheduleMapper;

    /**
     * 获取医生排班信息
     * @param doctorId 医生ID
     * @return 排班列表
     */
    public List<DoctorSchedule> getDoctorSchedule(Integer doctorId) {
        log.info("Fetching schedule for doctor ID: {}", doctorId);
        List<DoctorSchedule> schedules = scheduleMapper.findByDoctorId(doctorId);
        
        // 添加详细日志
        schedules.forEach(schedule -> {
            log.info("Schedule: id={}, doctorId={}, date={}, period={}, slots={}", 
                schedule.getId(),
                schedule.getDoctorId(),
                schedule.getScheduleDate(),
                schedule.getTimePeriod(),
                schedule.getAvailableSlots()
            );
        });
        
        return schedules;
    }
} 